﻿/****************************************************************************
Copyright (c) 2014-2015 凌惊雪 微信:Lingjingxue 邮箱:lingjingxue@sina.com QQ:271487457

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/

using ServerBase.LunarSocket;
using ServerBase.Protocol;
using UtilLib;
using static ServerBase.Config.Conf;
using static ServerBase.Service.BaseDispatch;
using static UtilPublic.Redis.ServerRedis;
using ServerGame.Service;
using System.Collections.Generic;
using UtilPublic.ServerLoger;
using ServerBase.Service;
using ServerBase.Config;
using static ServerGame.Service.Dispatcher;
using ServerBase.Client;
using System;
using ServerPublic.Data;
using ServerGame.GameObject;
using static UtilPublic.Serialization.Jsh;
using ServerPublic.DataBaseMysql;
using UtilPublic.ApiDispatcher;
using ServerGame.Data;
using System.Text;

namespace ServerGame.Manager
{
    /// <summary>
    /// 管理 Efun
    /// </summary>
    public static partial class Efun
    {
        public static readonly string NOR = "#NOR#";
        
        public static string GenderSelf(string sex)
        {
            return "你";
        }
        public static string GenderPronoun(string sex)
        {
            switch (sex)
            {
                case "男性": 
                    return "他";
                case "女性": 
                    return "她";
                default: 
                    break;
            }
            return "它";
        }
        public static string QueryRude(int age, string gender, EClasss classs)
        {
            if (gender == "女性")
            {
                switch (classs)
                {
                    case EClasss.仙:
                        return true switch
                        {
                            _ when age < 30 => "小妖精",
                            _ when age < 50 => "妖女",
                            _ => "老妖婆"
                        };
                    case EClasss.妖魔:
                        return true switch
                        {
                            _ when age < 30 => "小妖女",
                            _ when age < 50 => "妖女",
                            _ => "老妖婆"
                        };
                    case EClasss.神:
                        return true switch
                        {
                            _ when age < 30 => "小妖女",
                            _ when age < 50 => "妖女",
                            _ => "老妖婆"
                        };
                    case EClasss.僧:
                        return true switch
                        {
                            _ when age < 30 => "小贼尼",
                            _ when age < 50 => "贼尼",
                            _ => "老贼尼"
                        };
                    case EClasss.道:
                        return true switch
                        {
                            _ when age < 30 => "小妖女",
                            _ when age < 50 => "妖女",
                            _ => "老妖婆"
                        };
                    default:
                        return true switch
                        {
                            _ when age < 30 => "小贱人",
                            _ when age < 50 => "贱人",
                            _ => "死老太婆"
                        };
                }
            }
            else
            {
                switch (classs)
                {
                    case EClasss.仙:
                        return true switch
                        {
                            _ when age < 50 => "死妖怪",
                            _ => "老妖怪"
                        };
                    case EClasss.妖魔:
                        return true switch
                        {
                            _ when age < 50 => "死妖怪",
                            _ => "老妖怪"
                        };
                    case EClasss.神:
                        return "死牛鼻子";
                    case EClasss.僧:
                        return true switch
                        {
                            _ when age < 50 => "死秃驴",
                            _ => "老秃驴"
                        };
                    case EClasss.道:
                        return "死牛鼻子";
                    case EClasss.儒:
                        return true switch
                        {
                            _ when age < 18 => "小书呆子",
                            _ when age < 50 => "臭书呆子",
                            _ => "老童生"
                        };
                    default:
                        return true switch
                        {
                            _ when age < 30 => "小王八蛋",
                            _ when age < 50 => "臭贼",
                            _ => "老匹夫"
                        };
                }
            }
        }


        public static string[] ListChDigit = { "零", "十", "百", "千", "万", "亿", "兆" };
        public static string[] ListChNum = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" };
        public static string[] ListChTien = { "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
        public static string[] ListChDee = { "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
        /// <summary>
        /// 中文数字 ChineseNumber
        /// </summary>
        /// <returns></returns>
        public static string ChineseNumber(long i)
        {
            if (i < 0) return "负" + ChineseNumber(-i);
            if (i < 11) return ListChNum[i];
            if (i < 20) return ListChNum[10] + ListChNum[i - 10];
            if (i < 100)
            {
                if (i % 10 == 0) return ListChNum[i / 10] + ListChDigit[1];
                else return ListChNum[i / 10] + ListChDigit[1] + ListChNum[i % 10];
            }
            if (i < 1000)
            {
                if (i % 100 == 0)
                    return ListChNum[i / 100] + ListChDigit[2];
                else if (i % 100 < 10)
                    return ListChNum[i / 100] + ListChDigit[2] + ListChNum[0] + ChineseNumber(i % 100);
                else if (i % 100 < 20)
                    return ListChNum[i / 100] + ListChDigit[2] + ListChNum[1] + ChineseNumber(i % 100);
                else return ListChNum[i / 100] + ListChDigit[2] + ChineseNumber(i % 100);
            }
            if (i < 10000)
            {
                if (i % 1000 == 0)
                    return ListChNum[i / 1000] + ListChDigit[3];
                else if (i % 1000 < 100)
                    return ListChNum[i / 1000] + ListChDigit[3] + ListChDigit[0] + ChineseNumber(i % 1000);
                else
                    return ListChNum[i / 1000] + ListChDigit[3] + ChineseNumber(i % 1000);
            }
            if (i < 100000000)
            {
                if (i % 10000 == 0)
                    return ChineseNumber(i / 10000) + ListChDigit[4];
                else if (i % 10000 < 1000)
                    return ChineseNumber(i / 10000) + ListChDigit[4] + ListChDigit[0] + ChineseNumber(i % 10000);
                else
                    return ChineseNumber(i / 10000) + ListChDigit[4] + ChineseNumber(i % 10000);
            }
            if (i < 1000000000000)
            {
                if (i % 100000000 == 0)
                    return ChineseNumber(i / 100000000) + ListChDigit[5];
                else if (i % 100000000 < 10000000)
                    return ChineseNumber(i / 100000000) + ListChDigit[5] + ListChDigit[0] + ChineseNumber(i % 100000000);
                else
                    return ChineseNumber(i / 100000000) + ListChDigit[5] + ChineseNumber(i % 100000000);
            }
            if (i % 1000000000000 == 0)
                return ChineseNumber(i / 1000000000000) + ListChDigit[6];
            else if (i % 1000000000000 < 100000000000)
                return ChineseNumber(i / 1000000000000) + ListChDigit[6] + ListChDigit[0] + ChineseNumber(i % 1000000000000);
            else
                return ChineseNumber(i / 1000000000000) + ListChDigit[6] + ChineseNumber(i % 1000000000000);
        }
        public const long BvalueSilver = 100;
        public const long BvalueGold = 10000;
        /// <summary>
        /// 中文钱 ChineseMoney
        /// </summary>
        /// <returns></returns>
        public static string ChineseMoney(long i)
        {
            StringBuilder sb = new StringBuilder();
            long sum = Math.Max(i, 0);
            var gamount = sum / BvalueGold;
            var samount = (sum - (gamount * BvalueGold)) / BvalueSilver;
            var camount = sum % BvalueSilver;
            if (gamount >= 1)
            {
                sb.Append($"{ChineseNumber(gamount)}两#HIY#黄金");
            }
            if (samount >= 1)
            {
                sb.Append($"{ChineseNumber(samount)}两#WHT#白银");
            }
            sb.Append($"{ChineseNumber(camount)}文#YEL#铜板");
            return sb.ToString();
        }


        

    }
}
